package com.hyzh.latte.vehicle.dmo;

import com.hyzh.latte.util.gather.EarlyWarningPublicDTO;
import com.hyzh.latte.vehicle.dmo.entity.ParkPGEntity;
import lombok.*;

import java.io.Serializable;
import java.util.Optional;

/**
 * 和算法 对接
 * 人员报警数据 需要商定
 * @author songkui
 * @since 2024/3/20 14:05
 */
@Getter
@Setter
@NoArgsConstructor
@ToString(exclude = {"img"})
@AllArgsConstructor
@EqualsAndHashCode(of ={"lon", "lat"})
public class PersonAlarmDTO implements Serializable {

    private String cno ; // 摄像头编号
    private String cip; // 摄像头IP
    private Integer cp; //摄像头端口

    private Integer num;  //人数
    private String lon;   // 经度度
    private String lat;   // 维度
    private String img;   // 图片base64

    public EarlyWarningPublicDTO buildEarlyWarningPublicDTO(ParkPGEntity parkPGEntity){
        EarlyWarningPublicDTO dto = new EarlyWarningPublicDTO();
        dto.setIp(this.cip);
        Optional.ofNullable(this.cp).ifPresent(x -> dto.setPortNumber(String.valueOf(x)));
        dto.setDeviceCode(this.cno);
        dto.setParkCode(parkPGEntity.getFormalCode());
        dto.setLatitude(this.lat);
        dto.setLongitude(this.lon);
        dto.setFileBase64(this.img);
        return dto;
    }

    public PersonGatherDTO buildPersonGatherDTO(){
        PersonGatherDTO personGatherDTO = new PersonGatherDTO();
        personGatherDTO.setPersonNum(this.num);
        personGatherDTO.setLon(this.lon);
        personGatherDTO.setLat(this.lat);
        return personGatherDTO;
    }

}
